﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace GUI.Tabs
{
    class MessageBoxAlerts : IAlerts
    {
        public Window Owner { get; private set; }

        public MessageBoxAlerts(Window w)
        {
            Owner = w;
        }

        public void Alert(string msg)
        {
            Owner.Dispatcher.Invoke((Action)delegate()
            {
                System.Windows.MessageBox.Show(Owner, msg);
            });
        }

        public bool Confirm(string msg)
        {
            return (bool)Owner.Dispatcher.Invoke((Func<bool>)delegate()
            {
                return System.Windows.MessageBox.Show(
                    Owner,
                    msg,
                    "Confirmation",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question) == MessageBoxResult.Yes;
            });
        }

        public void Error(string msg)
        {
            Owner.Dispatcher.Invoke((Action)delegate()
            {
                System.Windows.MessageBox.Show(Owner, msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            });
        }
    }
}
